<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <!-- INTERFACE -->
    <cc:interface>
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <p:dialog id="dialogChannelAdded" header="Add Chiled Item" widgetVar="dlgAdd" 
                  modal="true" height="400" width="600">


            <h:panelGroup id="panelInventoryItemDetails" >

                <p:panelGrid styleClass="alignTop"  columns="2"
                             rendered="#{storeGrnController.parentBillItem.item.departmentType eq 'Inventry'}" >


                    <h:outputLabel value="Select Item"/>                             
                    <p:autoComplete id="acItem" 
                                    value="#{storeGrnController.currentBillItem.item}" 
                                    forceSelection="true"
                                    completeMethod="#{itemController.completeStoreItem}" 
                                    var="vt" itemLabel="#{vt.name}" itemValue="#{vt}" >
                        <p:column headerText="Item" >
                            <h:outputLabel value="#{vt.name}"></h:outputLabel>
                        </p:column>
                        <p:column headerText="Code" >
                            <h:outputLabel value="#{vt.code}"></h:outputLabel>
                        </p:column>
                        <p:column headerText="Pack Size" >
                            <p:outputLabel value=" X #{vt.dblValue}" 
                                           rendered="#{vt.class eq 'class com.divudi.entity.pharmacy.Ampp'}"/>                            
                        </p:column>
                        <p:column headerText="Pack Size" >
                            <p:outputLabel value=" X #{vt.dblValue}" 
                                           rendered="#{vt.class eq 'class com.divudi.entity.pharmacy.Ampp'}"/>                            
                        </p:column>
                        <p:column headerText="Pack Size" >
                            <p:outputLabel value=" X #{vt.dblValue}" 
                                           rendered="#{vt.class eq 'class com.divudi.entity.pharmacy.Ampp'}"/>                            
                        </p:column>
                        <f:ajax event="itemSelect" execute="@this" render="txtInventoryCode" 
                                listener="#{storeGrnController.createSerialNumber()}" ></f:ajax>
                    </p:autoComplete>
                    <h:outputLabel value="Qty"/>
                    <p:inputText autocomplete="off" id="txtQty" styleClass="numericTxt" 
                                 value="#{storeGrnController.currentBillItem.tmpQty}" style="width:100%" />  
                    <h:outputLabel value="Free"/>
                    <p:inputText autocomplete="off" id="txtFreeQty"  styleClass="numericTxt" 
                                 value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.freeQty}" style="width:100%" /> 
                    <h:outputLabel value="Purchase Rate"/>
                    <p:inputText autocomplete="off" id="txtPrate"  styleClass="numericTxt" 
                                 value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.purchaseRate}"  >
                        <f:ajax event="blur" execute="@this" render="tmpRetail" 
                                listener="#{storeGrnController.purchaseRateListener(storeGrnController.currentBillItem.pharmaceuticalBillItem)}"/>
                    </p:inputText>
                    <h:outputLabel value="Sale Price"/>
                    <p:inputText autocomplete="off" id="tmpRetail"  styleClass="numericTxt" 
                                 value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.retailRate}"  />  
                    <h:outputLabel value="DOE(dd mm yy)/Warrenty Date"/>
                    <p:calendar navigator="true"
                                id="calDoe" pattern="dd MM yy" value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.doe}"   >
                        <f:ajax event="dateSelect" execute="@this" render="tmp" listener="#{storeGrnController.setBatch()}"/>
                    </p:calendar> 
                    <h:outputLabel value="Bathch No"/>
                    <p:inputText autocomplete="off"  styleClass="numericTxt" 
                                 id="tmp" value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.stringValue}"  />
                    <h:outputLabel value="Make"/>
                    <p:selectOneMenu id="cmbMake" value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.make}" >
                        <f:selectItem itemLabel="Select a Make" ></f:selectItem>
                        <f:selectItems value="#{makeController.items}" var="make" itemLabel="#{make.name}" itemValue="#{make}" ></f:selectItems>
                    </p:selectOneMenu>
                    <h:outputLabel value="Model"/>
                    <p:inputText value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.model}" />
                    <h:outputLabel value="Inventory Code"/>
                    <p:inputText id="txtInventoryCode" 
                                 value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.code}" />                                
                    <h:outputLabel value="Description"/>
                    <p:inputTextarea id="txtInventoryDescription" 
                                     value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.description}" />
                    <h:outputLabel value="Barcode No"/>
                    <p:inputText id="txtBarcode" value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.barcode}" />
                    <h:outputLabel value="Serial No"/>
                    <p:inputText id="txtSerialNo" value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.serialNo}" />
                    <h:outputLabel value="Registration No"/>
                    <p:inputText id="txtRegNo" value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.registrationNo}" ></p:inputText>
                    <h:outputLabel value="Chassis No"/>
                    <p:inputText id="txtChassisNo" value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.chassisNo}" ></p:inputText>
                    <h:outputLabel value="Engine No"/>
                    <p:inputText id="txtEngineNo" value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.engineNo}" ></p:inputText>
                    <h:outputLabel value="Colour"/>
                    <p:inputText id="txtColour" value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.colour}" ></p:inputText>
                    <h:outputLabel value="Warranty Certification No"/>
                    <p:inputText id="txtWarrentyCertificateNo" value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.warrentyCertificateNumber}" ></p:inputText>
                    <h:outputLabel value="Warranty Duration"/>
                    <p:outputLabel id="lblWarrantyDuration" value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.warrentyDuration}" ></p:outputLabel>
                    <h:outputLabel value="Depreciation Rate"/>
                    <p:inputText id="txtDepreciationRate" value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.deprecitionRate}" ></p:inputText>
                    <h:outputLabel value="Manufacturer"/>
                    <p:autoComplete id="acManufacturer" value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.manufacturer}"
                                    completeMethod="#{manufacturerController.completeManu}" 
                                    var="manufacturer"
                                    itemLabel="#{manufacturer.name}"
                                    itemValue="#{manufacturer}" ></p:autoComplete>
                    <h:outputLabel value="Other Notes"/>
                    <p:inputTextarea id="txtOtherNotes" 
                                     value="#{storeGrnController.currentBillItem.pharmaceuticalBillItem.otherNotes}" >
                    </p:inputTextarea>

                    <p:commandButton id="btnAdd" value="Add Item" 
                                    action="#{storeGrnController.addItem}" 
                                   ajax="false"/>


                </p:panelGrid>


            </h:panelGroup>


        </p:dialog>  
    </cc:implementation>
</html>